package com.pro.control;

import com.pro.dao.CourseClassMapper;
import com.pro.entity.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @ClassName: CourseClassController
 * @Author: 笑笑
 * @DATE: 2021/11/25
 * @TIME: 下午 06:27
 */
@RestController
@RequestMapping("/CourseClass")
public class CourseClassController {
    @Resource
    private CourseClassMapper courseClassMapper;

    @RequestMapping("/getIdByName")
    public JsonData getIdByName(String className){
        if (className == null || "".equals(className)){
            try {
                throw new Exception("课程分类名不能为空");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        Integer idByName = courseClassMapper.getIdByName(className);
        return idByName != null ? JsonData.buildSuccess(idByName) : JsonData.buildError("没有查到");
    }
}
